package com.example.go_drink_water_plugin.component;

import com.example.go_drink_water_plugin.AppConfig;
import com.example.go_drink_water_plugin.ReminderTask;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

public class DrinkWaterNotification extends Notification {
    public DrinkWaterNotification(Project project) {
        super("PluginGroupId",
                "喝水提醒",
                "欢迎使用水分提醒！点击这里设置您的喝水计划，保持健康，提高工作效率", NotificationType.INFORMATION);

        // 添加设置按钮
        this.addAction(new NotificationAction("设置") {
            @Override
            public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                openSettingsDialog();
            }
        });

        // 添加默认配置启动按钮
        this.addAction(new NotificationAction(" 默认开启 ") {
            @Override
            public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                // 启动默认配置
                startDefaultConfiguration();
                notification.expire();
            }
        });
    }

    private void openSettingsDialog() {
        // 实现打开设置对话框的逻辑
        SettingsDialogDelegate.toConfig();
    }

    private void startDefaultConfiguration() {
        AppConfig.isReminderEnabled = true;
        AppConfig.reminderInterval = 10;
        ReminderTask.startReminder(AppConfig.reminderInterval);
    }


}
